What is Polymorphism?
Poly means many and morph means forms. In C++, polymorphism means the same function name or interface can behave differently depending on the object type or runtime context.
There are two main types:
- Compile-time polymorphism - function overloading, operator overloading
- Run-time polymorphism - achieved using virtual functions